function reduceCount() {
  const that = this;
  let quantity = that.data.quantity || 1;
  let price = that.data.price || 0;
  let totalPrice = 0;
  if(quantity == 1) return false;
  quantity --;
  totalPrice = that.getTotalPrice(quantity, price);
  that.setData({
    quantity,
    totalPrice,
  })
}

function addCount() {
  const that = this;
  let quantity = that.data.quantity || 1;
  let price = that.data.price || 0;
  let totalPrice = 0;
  quantity++;
  totalPrice = that.getTotalPrice(quantity, price);
  that.setData({
    quantity,
    totalPrice,
  })
}

function getTotalPrice(quantity, price) {
  return quantity * (price * 1000) / 1000;
}

export default {
  reduceCount,
  addCount,
  getTotalPrice,
}